@extends('admin.layout.index')


@section('content')
<div class="mws-panel grid_8">
	<div class="mws-panel-header">
		<span>
			<i class="icon-table"></i>&nbsp;&nbsp;@if($data && $data['0']['gstatus']==1) 上架商品
													@endif


													@if($data && $data['0']['gstatus']==2) 下架商品
													@endif

													@if($data && $data['0']['gsum'] < 30 && $data['0']['gstatus'] == 1) (低库存)
													@endif

													@if(!($data)) 无商品
													@endif
		</span>
	</div>
	<div class="mws-panel-body no-padding">
		<div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">
			<div id="DataTables_Table_1_length" class="dataTables_length">
				<form @if($data['gstatus'] == 1) action="/admin/goods/index" @endif
					  @if($data['gstatus'] == 2) action="/admin/goods/out" @endif
					  @if($data['gum'] < 30 && $data['gstatus'] == 1) action="/admin/goods/less" @endif
				method='get'>
				<label>显示
					<select size="1" name="count" aria-controls="DataTables_Table_1">
						<option value="10" @if(!empty($request['count'])&& $request['count']==10) selected @endif>10</option>
						<option value="20" @if(!empty($request['count'])&& $request['count']==20) selected @endif>20</option> 
						<option value="30" @if(!empty($request['count'])&& $request['count']==30) selected @endif>30</option>
						</select>&nbsp;条</label>
			</div>
			<div class="dataTables_filter" id="DataTables_Table_1_filter">
				<label>关键字:
					<input type="text" name='search' value="{{ $request['search'] or ''}}"></label>
					<input type="submit" value="搜索">
				</form>
			</div>
			<table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
				<thead>
					<tr role="row">
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 156px;">商品编号</th>
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 208px;">商品名称</th>
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 194px;">商品图片</th>
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 136px;">商品价格</th>
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 136px;">商品数量</th>
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 136px;">上架时间</th>
						@if($data && $data['0']['gstatus']==2)
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 136px;">下架时间</th> 
						@endif
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 136px;">状态</th>
						<th role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width: 101px;">操作</th></tr>
				</thead>
				<tbody role="alert" aria-live="polite" aria-relevant="all">
					@foreach($data as $k=>$v)
					<tr class="odd">
						<td class=" sorting_1" style=''>{{$v['gid']}}</td>
						<td class=" ">{{$v['gname']}}</td>
						<td class=" "><img src="/smallgoods/{{$v['gphoto']}}" alt="{{$v['gname']}}" style="width:50px; height:50px"></td>
						<td class=" ">{{$v['ghyprice']}}</td>
						<td class=" ">{{$v['gsum']}}</td>
						<td class=" ">{{ date('Y-m-d H:i:s',$v['starttime']) }}</td>
						@if($data && $data['0']['gstatus']==2)
						<td class=" ">{{ date('Y-m-d H:i:s',$v['endtime']) }}</td>
						@endif
						<td class=" ">@if ($v['gstatus'] == 1) 上架中
									  @endif
									  @if ($v['gstatus'] == 2) 已下架
									  @endif
						</td>
						<td class=" " style =" width:15%;">
									  <a href="/admin/goods/edit/{{$v['gid']}}" title='修改信息' style="color:purple">修改</a>
									  &nbsp;
									  @if ($v['gstatus'] == 1)
									  <a href="/admin/goods/xjgoods/{{$v['gid']}}" title='下架商品' style="color:gray" onclick="return confirm('确定下架？')">下架</a>
									  @endif
									  @if ($v['gstatus'] == 2)
									  <a href="/admin/goods/xjgoods/{{$v['gid']}}" title='上架商品' style="color:green" onclick="return confirm('确定上架？')">上架</a>
									  @endif
									  &nbsp;
									  @if ($v['gstatus'] == 2)
									  <a href="/admin/goods/del/{{$v['gid']}}" title='删除商品' style="color:red" onclick="return confirm('确定删除？')">删除</a>
									  @endif
						</td>
					</tr>
					@endforeach
				</tbody>
			</table>
			
				<div id='page_page'>
					{!! $data->appends($request)->render() !!}
				</div>
			</div>

		</div>
	</div>
</div>
@endsection